package com.junko.model;

public class JsonResult {
    private Boolean success;
    private Integer code;
    private String msg;
    private Object data;

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public JsonResult(Boolean success, Integer code, String msg, Object data) {
        this.success = success;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static JsonResult fail(){
        return new JsonResult(false,500,"操作失败",null);
    }

    /**
     * 自定义失败参数
     * @param msg   错误信息
     * @return
     */
    public static JsonResult fail(String msg){
        return new JsonResult(false,500,msg,null);
    }
    /**
     * 自定义失败参数
     * @param code  错误码
     * @param msg   错误信息
     * @return
     */
    public static JsonResult fail(Integer code,String msg){
        return new JsonResult(false,code,msg,null);
    }
    public static JsonResult fail(Integer code,String msg,Object data){
        return new JsonResult(false,code,msg,data);
    }
    public static JsonResult fail(String msg,Object data){
        return new JsonResult(false,500,msg,data);
    }

    /**
     * 成功操作
     * @return
     */
    public static JsonResult success(){
        return new JsonResult(true,200,null,null);
    }

    /**
     * 成功操作
     * @param data
     * @return
     */
    public static JsonResult success(Object data){
        return new JsonResult(true,200,null,data);
    }
    /**
     * 成功操作
     * @param msg
     * @return
     */
    public static JsonResult success(String msg){
        return new JsonResult(true,200,msg,null);
    }

    /**
     * 自定义成功参数
     * @param code  成功码
     * @param msg   成功信息
     * @param data  数据
     * @return
     */
    public static JsonResult success(Integer code,String msg,Object data){
        return new JsonResult(true,code,msg,data);
    }
}
